package logic

import (
	"context"
	"videos/model/mysql"

	"videos/videorpc/internal/svc"
	"videos/videorpc/videorpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type CollectionDetailLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCollectionDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CollectionDetailLogic {
	return &CollectionDetailLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *CollectionDetailLogic) CollectionDetail(in *videorpc.CollectionDetailRequest) (*videorpc.CollectionDetailResponse, error) {
	// todo: add your logic here and delete this line

	var collection mysql.CollectionUserVideo

	err := collection.CollectionDetail(mysql.DB, in.CollectionId)
	if err != nil {
		return nil, err
	}

	return &videorpc.CollectionDetailResponse{
		CollectionId: int64(collection.CollectionId),
		NickName:     collection.NickName,
		Title:        collection.Title,
	}, nil
}
